#ifndef __SEMAPHORE_H
#define __SEMAPHORE_H

#include "SDL/SDL.h"

/**
 * Représente un sémaphore, les copains d'abord.
 */
class semaphore
{
	SDL_sem *mon_semaphore_;
public:
	semaphore(int initiale) : mon_semaphore_(SDL_CreateSemaphore(initiale)) {}
	bool obtenir() const throw() { return SDL_SemWait(mon_semaphore_) == 0; }
	bool relacher() const throw() { return SDL_SemPost(mon_semaphore_) == 0; }
	~semaphore() throw() { SDL_DestroySemaphore(mon_semaphore_); }
};

#endif
